/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package EA_Model.IEC61970.Wires.impl;

import EA_Model.IEC61970.Domain.Reactance;
import EA_Model.IEC61970.Domain.Voltage;
import EA_Model.IEC61970.Domain.VoltagePerReactivePower;

import EA_Model.IEC61970.Wires.SVCControlMode;
import EA_Model.IEC61970.Wires.StaticVarCompensator;
import EA_Model.IEC61970.Wires.WiresPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Static Var Compensator</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.StaticVarCompensatorImpl#getCapacitiveRating <em>Capacitive Rating</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.StaticVarCompensatorImpl#getInductiveRating <em>Inductive Rating</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.StaticVarCompensatorImpl#getSlope <em>Slope</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.StaticVarCompensatorImpl#getSVCControlMode <em>SVC Control Mode</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.StaticVarCompensatorImpl#getVoltageSetPoint <em>Voltage Set Point</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StaticVarCompensatorImpl extends RegulatingCondEqImpl implements StaticVarCompensator {
	/**
	 * The cached value of the '{@link #getCapacitiveRating() <em>Capacitive Rating</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCapacitiveRating()
	 * @generated
	 * @ordered
	 */
	protected Reactance capacitiveRating;

	/**
	 * The cached value of the '{@link #getInductiveRating() <em>Inductive Rating</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInductiveRating()
	 * @generated
	 * @ordered
	 */
	protected Reactance inductiveRating;

	/**
	 * The cached value of the '{@link #getSlope() <em>Slope</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSlope()
	 * @generated
	 * @ordered
	 */
	protected VoltagePerReactivePower slope;

	/**
	 * The default value of the '{@link #getSVCControlMode() <em>SVC Control Mode</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSVCControlMode()
	 * @generated
	 * @ordered
	 */
	protected static final SVCControlMode SVC_CONTROL_MODE_EDEFAULT = SVCControlMode.REACTIVE_POWER;

	/**
	 * The cached value of the '{@link #getSVCControlMode() <em>SVC Control Mode</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSVCControlMode()
	 * @generated
	 * @ordered
	 */
	protected SVCControlMode sVCControlMode = SVC_CONTROL_MODE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getVoltageSetPoint() <em>Voltage Set Point</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVoltageSetPoint()
	 * @generated
	 * @ordered
	 */
	protected Voltage voltageSetPoint;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StaticVarCompensatorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WiresPackage.Literals.STATIC_VAR_COMPENSATOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance getCapacitiveRating() {
		if (capacitiveRating != null && capacitiveRating.eIsProxy()) {
			InternalEObject oldCapacitiveRating = (InternalEObject)capacitiveRating;
			capacitiveRating = (Reactance)eResolveProxy(oldCapacitiveRating);
			if (capacitiveRating != oldCapacitiveRating) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.STATIC_VAR_COMPENSATOR__CAPACITIVE_RATING, oldCapacitiveRating, capacitiveRating));
			}
		}
		return capacitiveRating;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance basicGetCapacitiveRating() {
		return capacitiveRating;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCapacitiveRating(Reactance newCapacitiveRating) {
		Reactance oldCapacitiveRating = capacitiveRating;
		capacitiveRating = newCapacitiveRating;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.STATIC_VAR_COMPENSATOR__CAPACITIVE_RATING, oldCapacitiveRating, capacitiveRating));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance getInductiveRating() {
		if (inductiveRating != null && inductiveRating.eIsProxy()) {
			InternalEObject oldInductiveRating = (InternalEObject)inductiveRating;
			inductiveRating = (Reactance)eResolveProxy(oldInductiveRating);
			if (inductiveRating != oldInductiveRating) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.STATIC_VAR_COMPENSATOR__INDUCTIVE_RATING, oldInductiveRating, inductiveRating));
			}
		}
		return inductiveRating;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance basicGetInductiveRating() {
		return inductiveRating;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInductiveRating(Reactance newInductiveRating) {
		Reactance oldInductiveRating = inductiveRating;
		inductiveRating = newInductiveRating;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.STATIC_VAR_COMPENSATOR__INDUCTIVE_RATING, oldInductiveRating, inductiveRating));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public VoltagePerReactivePower getSlope() {
		if (slope != null && slope.eIsProxy()) {
			InternalEObject oldSlope = (InternalEObject)slope;
			slope = (VoltagePerReactivePower)eResolveProxy(oldSlope);
			if (slope != oldSlope) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.STATIC_VAR_COMPENSATOR__SLOPE, oldSlope, slope));
			}
		}
		return slope;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public VoltagePerReactivePower basicGetSlope() {
		return slope;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSlope(VoltagePerReactivePower newSlope) {
		VoltagePerReactivePower oldSlope = slope;
		slope = newSlope;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.STATIC_VAR_COMPENSATOR__SLOPE, oldSlope, slope));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SVCControlMode getSVCControlMode() {
		return sVCControlMode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSVCControlMode(SVCControlMode newSVCControlMode) {
		SVCControlMode oldSVCControlMode = sVCControlMode;
		sVCControlMode = newSVCControlMode == null ? SVC_CONTROL_MODE_EDEFAULT : newSVCControlMode;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.STATIC_VAR_COMPENSATOR__SVC_CONTROL_MODE, oldSVCControlMode, sVCControlMode));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage getVoltageSetPoint() {
		if (voltageSetPoint != null && voltageSetPoint.eIsProxy()) {
			InternalEObject oldVoltageSetPoint = (InternalEObject)voltageSetPoint;
			voltageSetPoint = (Voltage)eResolveProxy(oldVoltageSetPoint);
			if (voltageSetPoint != oldVoltageSetPoint) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.STATIC_VAR_COMPENSATOR__VOLTAGE_SET_POINT, oldVoltageSetPoint, voltageSetPoint));
			}
		}
		return voltageSetPoint;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage basicGetVoltageSetPoint() {
		return voltageSetPoint;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setVoltageSetPoint(Voltage newVoltageSetPoint) {
		Voltage oldVoltageSetPoint = voltageSetPoint;
		voltageSetPoint = newVoltageSetPoint;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.STATIC_VAR_COMPENSATOR__VOLTAGE_SET_POINT, oldVoltageSetPoint, voltageSetPoint));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WiresPackage.STATIC_VAR_COMPENSATOR__CAPACITIVE_RATING:
				if (resolve) return getCapacitiveRating();
				return basicGetCapacitiveRating();
			case WiresPackage.STATIC_VAR_COMPENSATOR__INDUCTIVE_RATING:
				if (resolve) return getInductiveRating();
				return basicGetInductiveRating();
			case WiresPackage.STATIC_VAR_COMPENSATOR__SLOPE:
				if (resolve) return getSlope();
				return basicGetSlope();
			case WiresPackage.STATIC_VAR_COMPENSATOR__SVC_CONTROL_MODE:
				return getSVCControlMode();
			case WiresPackage.STATIC_VAR_COMPENSATOR__VOLTAGE_SET_POINT:
				if (resolve) return getVoltageSetPoint();
				return basicGetVoltageSetPoint();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WiresPackage.STATIC_VAR_COMPENSATOR__CAPACITIVE_RATING:
				setCapacitiveRating((Reactance)newValue);
				return;
			case WiresPackage.STATIC_VAR_COMPENSATOR__INDUCTIVE_RATING:
				setInductiveRating((Reactance)newValue);
				return;
			case WiresPackage.STATIC_VAR_COMPENSATOR__SLOPE:
				setSlope((VoltagePerReactivePower)newValue);
				return;
			case WiresPackage.STATIC_VAR_COMPENSATOR__SVC_CONTROL_MODE:
				setSVCControlMode((SVCControlMode)newValue);
				return;
			case WiresPackage.STATIC_VAR_COMPENSATOR__VOLTAGE_SET_POINT:
				setVoltageSetPoint((Voltage)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WiresPackage.STATIC_VAR_COMPENSATOR__CAPACITIVE_RATING:
				setCapacitiveRating((Reactance)null);
				return;
			case WiresPackage.STATIC_VAR_COMPENSATOR__INDUCTIVE_RATING:
				setInductiveRating((Reactance)null);
				return;
			case WiresPackage.STATIC_VAR_COMPENSATOR__SLOPE:
				setSlope((VoltagePerReactivePower)null);
				return;
			case WiresPackage.STATIC_VAR_COMPENSATOR__SVC_CONTROL_MODE:
				setSVCControlMode(SVC_CONTROL_MODE_EDEFAULT);
				return;
			case WiresPackage.STATIC_VAR_COMPENSATOR__VOLTAGE_SET_POINT:
				setVoltageSetPoint((Voltage)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WiresPackage.STATIC_VAR_COMPENSATOR__CAPACITIVE_RATING:
				return capacitiveRating != null;
			case WiresPackage.STATIC_VAR_COMPENSATOR__INDUCTIVE_RATING:
				return inductiveRating != null;
			case WiresPackage.STATIC_VAR_COMPENSATOR__SLOPE:
				return slope != null;
			case WiresPackage.STATIC_VAR_COMPENSATOR__SVC_CONTROL_MODE:
				return sVCControlMode != SVC_CONTROL_MODE_EDEFAULT;
			case WiresPackage.STATIC_VAR_COMPENSATOR__VOLTAGE_SET_POINT:
				return voltageSetPoint != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (sVCControlMode: ");
		result.append(sVCControlMode);
		result.append(')');
		return result.toString();
	}

} //StaticVarCompensatorImpl
